﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
using System.Data.SqlClient;
using System.Data.Common;
namespace Ivy.Common.Framework.GeneralUtility
{
    public class FileUtility
    {
        #region  Variable & constant

        #endregion  Variable & constant

        #region Constructor & Destructor
        #endregion Constructor & Destructor

        #region Properties
        #endregion Properties

        #region Public Methods
        public bool WriteToLogFile(string pLinetext, string pFilepath)
        {
            bool IsOperationSuccessful = false;

            try
            {
                if (!File.Exists(pFilepath))
                {
                    File.Create(pFilepath).Dispose();
                    using (TextWriter tw = new StreamWriter(pFilepath))
                    {
                        tw.WriteLine(pLinetext);
                        tw.Close();
                        IsOperationSuccessful = true;
                    }
                }
                else
                {
                    using (TextWriter tw = new StreamWriter(pFilepath,true))
                    {
                        tw.WriteLine(pLinetext);
                        tw.Close();
                        IsOperationSuccessful = true;
                    }
                }
            }
            catch (Exception ex)
            {
                
                throw ex;
            }
            return IsOperationSuccessful;
        }
        #endregion Public Methods

        #region Events

        #endregion Events

        #region Private Methods
        #endregion Private Methods
    }
}
